package org.example.custom;

import org.example.util.JDBCUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Hello01DDL {
    public static void main(String[] args) throws SQLException {
        //获取数据库连接
        Connection connection = JDBCUtil.getConnection();
        String sql = "CREATE TABLE IF NOT EXISTS yjxxt.user\n" +
                "(\n" +
                " id Int32,\n" +
                " uname String,\n" +
                " passwd String,\n" +
                " createtime DateTime\n" +
                ") ENGINE = MergeTree()\n" +
                " PARTITION BY toYYYYMM(createtime)\n" +
                " ORDER BY id;";
        PreparedStatement statement = connection.prepareStatement(sql);
        //执行批处理
        statement.execute();
        //关闭连接
        JDBCUtil.closeAll(connection, statement, null);
    }
}
